package com.rms.hkpc.adapter;

import android.content.Context;
import android.widget.TextView;

import com.rms.hkpc.R;
import com.rms.hkpc.adapter.base.BaseAdapter;
import com.rms.hkpc.adapter.base.BaseViewHolder;
import com.rms.hkpc.db.dto.ShortDto;

import java.util.List;

public class DialogAdapter extends BaseAdapter<ShortDto> {
    public DialogAdapter(Context context, List<ShortDto> mDatas, int layoutId) {
        super(context, mDatas, layoutId);
    }

    @Override
    public void convert(BaseViewHolder holder, ShortDto item, int position) {
        TextView tv = holder.fd(R.id.tv_dialog);
        tv.setText(item.getName() == null ? "" : item.getName());
        if (item.getSelect() != null) {
            tv.setSelected(item.getSelect());
        }
    }

    public void changeSelect(int position){
        for (int i = 0;i < getItemCount();i ++){
            mData.get(i).setSelect(false);
        }
        mData.get(position).setSelect(true);
        notifyDataSetChanged();
    }
}
